package com.xuzz.study.springbootdemo.controller;

import com.xuzz.study.springboot.DemoService;
import com.xuzz.study.springbootdemo.entity.Response;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.io.Serializable;

@RestController
public class DemoController {

    @Resource
    DemoService demoService;

    @Resource(name="demoService1")
    DemoService demoService1;

    @Resource(name="demoService2")
    DemoService demoService2;

    @Resource(name="demoService3")
    DemoService demoService3;

    @Resource(name="demoService4")
    DemoService demoService4;

    @RequestMapping
    public Response testStarter()
    {
        return new Response().message(demoService.say());
    }

    @RequestMapping("import")
    public Response testImportDemo(){
        return new Response().message( "from @EnableDemo demoServer1:"+demoService1.say()+
                "\r\n from @EnableDemo demoServer2:"+demoService2.say());
    }

    @RequestMapping("importselector")
    public Response testImportSelectorDemo(){
        return new Response().message( "from @DemoApplication demoServer3:"+demoService3.say()+
                "\r\n from @DemoApplication demoServer4:"+demoService4.say());
    }
}
